package com.sun.dream.fish.session;

import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

/**
 * Description:  本地线程参数
 * Created By ljl on 2023/12/05.
 */
public class DSFSession extends HashMap<String, Object> implements Serializable {
    private static final String DSF_LOCALE = "DSF:LOCALE";
    private static final String DSF_ERROR = "DSF:ERROR";
    private static final String DSF_SESSIONPARAMETERS = "DSF:SESSIONPARAMETERS";

    protected DSFSession() {
    }

    public String getLocale() {
        return (String) get(DSF_LOCALE);
    }

    public void setLocale(String locale) {
        put(DSF_LOCALE, locale);
    }

    public List<String> getErrors() {
        return (List<String>) computeIfAbsent(DSF_ERROR, (key) -> new LinkedList<>());
    }

    public void addError(String error) {
        getErrors().add(error);
    }

    public SessionParameters getSessionParameters() {
        return (SessionParameters) get(DSF_SESSIONPARAMETERS);
    }
}
